<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('物流订单')" />
	<th:block th:include="include :: list-css" />
	<style type="text/css">
		.layui-tab-title{border-color: #ccc !important;}
		.layui-this{color: rgb(0, 135, 250) !important;background: none !important;}
		.layui-tab-brief > .layui-tab-title .layui-this:after, .layui-tab-brief > .layui-tab-more li.layui-this:after{border-color:  rgb(0, 135, 250) !important;}
		label.layui-form-label {width: 95px;padding-right: 0px;}
		.layui-form-radio {margin-top:0}
		.mid-content{overflow-y:auto}
		.importTable{empty-cells:show;border-collapse:collapse;border-spacing:0;}
		.listext th{background:#eee;color:#3366cc;}
		.listext th,.listext td{border:solid 1px #ddd;text-align:left;padding:10px;font-size:14px;}
		#importProgress {z-index:20200202;background-color: #000;opacity: 0.3;display:none;}
		.importProgress {width:300px;z-index:20202222;position: fixed;top: 34%;left: 40%;display:none;}
		.layui-form1 {padding: 16px 84px 16px 25px;}
		.getUpload{color: rgb(0, 135, 250);font-size: 18px;position: absolute;top:5px;right: 9px;}
	</style>
</head>
<body>
<div class="main-content">
	<div class="content-right">
		<div class="search-top">
			<span>查询条件</span>
			<a href="javascript:;" layadmin-event="flexible" class="menuBtn">
				<i class="layui-icon layui-icon-spread-left" id="LAY_app_flexible" style="color: #fff;"></i>
			</a>
		</div>
		<div class="panel layout-expand layui-expand-east">
			<div class="panel-header">
				<div class="panel-tool" style="text-align: center; width: 26px;height: 30px;line-height: 30px;">
					<a href="javascript:;" layadmin-event="flexible" class="menuBtn">
						<i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible" style="color: #fff;"></i>
					</a>
				</div>
			</div>
			<div class="panel-body panel-title" style="text-align: center; width: 26px;">查<br>询<br>条<br>件</div>
		</div>
		<form class="layui-form">
			<th:block th:include="listinclude :: searchRight('page')" />
		</form>
	</div>
	<div class="mid-content">
		<table class="layui-hide" id="dhtable" lay-filter="ftable"></table>
		<div class="spxx" style="display: none;">
			<div class="layui-tab layui-tab-brief demo2" lay-filter="demo2" style="position:relative;">
				<ul class="layui-tab-title">
					<li class="detailsName">拼票信息</li>
				</ul>
				<div class="layui-tab-content"></div>
			</div>
			<table class="layui-hide" id="pdhtable" lay-filter="pftable"></table>
		</div>
	</div>
</div>
<!-- 表格头部工作栏-->
<script type="text/html" id="toolbar">
	<div class="layui-btn-container">
		<div class="layui-btn layui-btn-normal layui-table-tools" lay-event="printList">
			<i class="dhicon dh-zu4250_2_2"></i> 打印发票清单
		</div>
		<div class="layui-btn layui-btn-normal layui-table-tools" lay-event="exportbtn">
			<i class="dhicon dh-zu4250_2_2"></i> 导出
		</div>
		<div class="layui-btn layui-btn-normal layui-table-tools" onclick="importBtn(4)" lay-event="importTrackingNum">
			<i class="dhicon dh-zu4250_2_2"></i> 批量导入追踪编号
		</div>
        <div class="layui-btn layui-table-tools importbtn-bg htbtn" lay-event="htbtn">
            <i class="dhicon layui-icon-prev"></i> 回退
        </div>
		<div class="layui-btn layui-table-tools importbtn-bg forcedRollback" lay-event="forcedRollback" th:if="${extraButton.forcedRollback}">
			<i class="dhicon layui-icon-prev"></i> 强制回退
		</div>
		<div class="layui-btn layui-btn-normal layui-table-tools" lay-event="isShipments">
			<i class="dhicon dh-zu4250_2_2"></i> 标记发货
		</div>
		<div class="layui-btn layui-btn-normal layui-table-tools" onclick="importBtn(5)" lay-event="batchDelivery">
			<i class="dhicon dh-zu4250_2_2"></i> 批量标记发货
		</div>
		<div class="layui-btn layui-table-tools importbtn-bg" lay-event="cancelTc">
			<i class="dhicon layui-icon-prev"></i> 上传头程追踪编号
		</div>
		<div class="layui-btn layui-btn-normal layui-table-tools" onclick="importBtn(6)" lay-event="importWaybillNumber">
			<i class="dhicon dh-zu4250_2_2"></i> 批量导入运单号
		</div>
		<div class="layui-btn layui-btn-normal layui-table-tools" lay-event="waybillNumber">
			<i class="dhicon dh-zu4250_2_2"></i> 导入运单号
		</div>
		<div class="layui-btn layui-btn-normal layui-table-tools" lay-event="addCEighty">
			<i class="dhicon dh-zu4250_2_2"></i> 上传C88数据
		</div>
	</div>
</script>

<script type="text/template" id="importTpl">
	<form enctype="multipart/form-data" class="mt20 mb10">
		<div class="col-xs-offset-1">
			<input type="file" id="file" name="file"/>
			<div class="mt10 pt5">
				<a onclick="$.tablelist.importTemplate('/logstics/fbabox/export?num')" class="btn btn-default btn-xs"><i class="dhicon dh-file-excel-o"></i> 下载模板</a>
			</div>
			<font color="red" class="pull-left mt10">提示：仅允许导入“xls”或“xlsx”格式文件！</font>
		</div>
	</form>
</script>
<!-- 导入明细 -->
<div id="iTable" class="display_no">
	<table class="importTable listext" data-resizable-columns-id="demo-table">
		<tbody id="itbody"></tbody>
	</table>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: businessJS" />
<th:block th:include="include :: searchJS" />
<th:block th:include="listinclude :: list-templeat" />
<script th:src="@{/dhecp/js/queryCondition.js}"></script>
<script th:inline="javascript">
	/*<![CDATA[*/
	var prefix = ctx + "logstics/fbaLogisticsOrder";
	var gridColumns = [[${gridColumns}]],
			importFields =[[${importFields}]],
			importFieldFH =[[${importFieldFH}]],
			importFieldYDH = [[${importFieldYDH}]],
			moduleTable =[[${moduleTable}]];
			ali1688EcpApiUrl = [[${ali1688EcpApiUrl}]];
	/*]]>*/
</script>
<script type="text/javascript">
	var element,thStr;
	var fieldWidth = {},		//导入列表字段宽度
			filedRequired = {},		//导入列表必填字段
			dateFiled = [],			//导入列表日期字段
			hasNull = false;		//导入数据必填字段有空值
	$.each(gridColumns.dictionaryForPageFieldList,function(i,v){
		fieldWidth[v.fields] = v.fieldFrontWidth
		if(v.fieldFrontRequired)filedRequired[v.fields] = v.fieldName;
		if(v.fieldFrontType == 't_date')dateFiled.push(v.fields);
	})
	var $,layer,laydate,form,table,wherestr={};
	layui.use(['table','laydate','form','layer','jquery','element'], function () {
		$ = layui.$, layer = layui.layer,laydate = layui.laydate , form = layui.form, table = layui.table, element = layui.element;
		serachRender();//查询条件初始渲染集合
		changeDropdown('fSl');//导入窗口——税率下拉可编辑赋事件
		$.tablelist.init({
			elem: '#dhtable'
			,modalName: "物流订单"
			,url: prefix + '/list'
			,updateUrl: prefix + "/edit?guid={id}"
			,initSort: {field: 'createTime',type: 'asc'}
			,totalRow: gridColumns.totalRow
			,cols: [gridColumns.gridBody]
			,toolbar: '#toolbar'
			,defaultToolbar: [{title:'列设置',layEvent: 'fieldSet',icon: 'layui-icon-set'}] //这里在右边显示
			,parseData: function(res){ //res 即为原始返回的数据
				var objpage=sessionStorage.getItem(moduleTable+'checkdata')
				if(objpage){
					objpage=JSON.parse(objpage)
					res.data.map((v,i)=>{
						objpage.map((n,m)=>{
							if(v.guid==n.guid){
								v.LAY_CHECKED=true
							}
						})
					})
				}
			}
			,done:function(res, curr, count){
				var ltv=this.elem.next('.layui-table-view');//当前table的dom
				res.data.length || count || ltv.find('.layui-table-header').css('display', 'inline-block');//数量为0时(统计报表存在不传count的情况)，表头赋予样式可拉动
				res.data.length || count || ltv.find('.layui-table-box').css('overflow-x', 'auto');//数量为0时(统计报表存在不传count的情况)，表头赋予样式可拉动
				if($('.spxx').is(':hidden')){
					$('.layui-table-body').eq(0).css('height', "75vh");
				}else{
					$('.layui-table-body').eq(0).css('height', "40vh");
				}
				fixTotal(this);//修复合计行固定列问题
				rowheight(res, curr);//修复合计行固定列问题
				if(typeof listTableDone == 'function')listTableDone();//如果查询列表存在表格加载完成回调事件，则执行
			}
		});
		//监听排序事件
		table.on('sort(ftable)', function(obj){
			$.tablelist.sort('dhtable',obj);
		});

		// 多选赋值
		sessionStorage.setItem(moduleTable+'checkdata','')
		table.on('checkbox(ftable)', function(obj){
			var objpage=sessionStorage.getItem(moduleTable+'checkdata')
			if(obj.type=='all'){//判断是否全选
				var objdata=table.checkStatus('dhtable')
				objdata=objdata.data
				if(obj.checked){//判断是否选中
					if(objpage){
						objpage=JSON.parse(objpage)
						objpage=objpage.concat(objdata)
						objpage=newData(objpage)
					}else{
						objpage=objdata
					}
				}else{
					var objpage=JSON.parse(objpage)
					var deldata=table.cache.dhtable
					objpage=delData(objpage,deldata)
				}
				sessionStorage.setItem(moduleTable+'checkdata',JSON.stringify(objpage))
			}else{//点击复选框
				if(objpage){
					objpage=JSON.parse(objpage)
					if(obj.checked){
						objpage.push(obj.data)
					}else{
						objpage.map((v,i)=>{
							if(v.guid==obj.data.guid){
								objpage.splice(i,1)
							}
						})
					}
				}else{
					objpage=[]
					objpage.push(obj.data)
				}
				sessionStorage.setItem(moduleTable+'checkdata',JSON.stringify(objpage))
			}
		});

		//头工具栏事件
		table.on('toolbar(ftable)', function(obj){
			switch(obj.event){
				case 'printList'://导出发票清单
					var objpage=sessionStorage.getItem(moduleTable+'checkdata')
					if(!objpage || objpage == '[]'){
						layer.msg("请先选择数据！");
					}else{
						$.modal.confirmCom('确定要导出发票清单么？',function(result){
							var infoItems=JSON.parse(objpage);
							urlSh = prefix+'/printList';
							$.ajax({
								url: urlSh,
								type: 'post',
								data: {infoItems:JSON.stringify(infoItems)},
								dataType: 'json',
								beforeSend: function () {
									showloadings(true);
								},
								success: function (result) {
									if (result.code == 0) {
										window.location.href = ctx + "common/download?fileName=" + encodeURIComponent(result.msg) + "&delete=" + true;
										parent.$('.page-loading').hide();//页面进行了跳转刷新，需要手动关闭页面的加载动画
										layer.closeAll();
										// $.modal.alert("发票清单导出成功!")
									} else if (result.code == web_status.WARNING) {
										$.modal.alertWarning(result.msg)
									} else {
										$.modal.alertError(result.msg);
									}
									showloadings(false);
								}
							});
						});
					}
					break;
				case 'fieldSet':
					filedSet(moduleTable);
					break;
				case "exportbtn"://导出
					$.ajax({
						url: prefix+'/export',
						type: 'GET',
						data: getWherestr(),
						dataType: 'json',
						beforeSend: function () {
							showloadings(true);
						},
						success: function (result) {
							if (result.code == 0) {
								window.location.href = ctx + "common/download?fileName=" + encodeURIComponent(result.msg) + "&delete=" + true;
								parent.$('.page-loading').hide();//页面进行了跳转刷新，需要手动关闭页面的加载动画
							} else if (result.code == web_status.WARNING) {
								$.modal.alertWarning(result.msg)
							} else {
								$.modal.alertError(result.msg);
							}
							showloadings(false);
						}
					});
					break;
				case 'htbtn'://回退
					var objpage=sessionStorage.getItem(moduleTable+'checkdata')
					if(!objpage || objpage == '[]'){
						layer.msg("请先选择数据！");
					}else {
						$.modal.confirmCom('确定要回退么？', function (result) {
							var infoItems = JSON.parse(objpage)
							if (infoItems.some(item => item.stateTrack == '4' || item.stateTrack == '5')) {
								layer.msg("选择单据中存在追踪编号已导入或者C88文件已导入,不允许回退!");
								return;
							}
							urlSh = prefix+'/htbtn';
							showloadings(true);
							$.operate.post(urlSh, {
								infoItems: JSON.stringify(infoItems),
								type:0
							}, function (result) {
								if (result.code == 0) {
									setTimeout(function () {
										sessionStorage.setItem(moduleTable + 'checkdata', '')
										showloadings(false);
										table.reload('dhtable', {page: {curr: 1}, where: getWherestr()});
									}, 1000);
								} else {
									showloadings(false);
								}
							});
						});
					}
					break;
				case 'forcedRollback'://强制回退
					var objpage=sessionStorage.getItem(moduleTable+'checkdata')
					if(!objpage || objpage == '[]'){
						layer.msg("请先选择数据！");
					}else {
						$.modal.confirmCom('确定要强制回退么？', function (result) {
							var infoItems = JSON.parse(objpage)
							urlSh = prefix+'/htbtn';
							showloadings(true);
							$.operate.post(urlSh, {
								infoItems: JSON.stringify(infoItems),
								type:1
							}, function (result) {
								if (result.code == 0) {
									setTimeout(function () {
										sessionStorage.setItem(moduleTable + 'checkdata', '')
										showloadings(false);
										table.reload('dhtable', {page: {curr: 1}, where: getWherestr()});
									}, 1000);
								} else {
									showloadings(false);
								}
							});
						});
					}
					break;
				case 'isShipments'://标记发货
					var objpage=sessionStorage.getItem(moduleTable+'checkdata')
					if(!objpage || objpage == '[]'){
						layer.msg("请先选择数据！");
					}else{
						$.modal.confirmCom('确定要标记发货么？',function(result){
							var infoItems=JSON.parse(objpage);
							if (infoItems.some(item => item.stateTrack != '2')) {
								layer.msg("选择单据中存在不是发票清单已打出状态,请核实后在操作!");
								return;
							}
							showloadings(true);
							$.operate.post(prefix + '/isShipments',{infoItems:JSON.stringify(infoItems)},function(result){
								if (result.code == 0){
									setTimeout(function(){
										sessionStorage.setItem(moduleTable+'checkdata','')
										showloadings(false);
										table.reload('dhtable', {page: {curr: 1},where:getWherestr()});
									}, 1000);
								} else {
									showloadings(false);
								}
							});
						});
					}
					break;
				case 'waybillNumber'://导入运单号
					var objpage=sessionStorage.getItem(moduleTable+'checkdata')
					if(!objpage || objpage == '[]'){
						layer.msg("请先选择数据！");
					}else{
						var infoItems=JSON.parse(objpage);
						if(infoItems.length > 1) {
							layer.msg("选择单据只允许选择一条数据,请核实后在操作!！");
							return;
						}
						if (infoItems.some(item => item.state != '0')) {
							layer.msg("选择单据订单状态不允许导入运单号,请核实后在操作!");
							return;
						}
						layer.confirm('确定要导入运单号么?', {
							icon: 3,
							offset: '10%',
							title: "系统提示",
							btn: ['确认', '取消'],
							shadeClose:true,
							yes: function(index){
								//确认关闭当前diglog
								layer.closeAll('dialog');
								//填写备注
								layer.open({
									type: 1,
									area: ['354px', '178px'],
									title: '导入运单号',
									offset: '20%',
									shadeClose:true,
									content: `
										<div class="layui-form-item">
											<label class="layui-form-label"><i style="color:red">*&nbsp;&nbsp;</i>物流运单号</label>
											<div class="layui-input-block">
												<input type="text" name="waybillNumber" required  lay-verify="required" placeholder="请输入物流运单号" autocomplete="off" class="layui-input waybillNumber"
												maxlength="20">
											</div>
										</div>
									`,
									btn: ['确认', '取消'],
									yes: function (index, layero) {
										var waybillNumber = $('.waybillNumber').val().trim()
										if (waybillNumber.replace(/(^\s*)|(\s*$)/g, "") == "") {
											return layer.msg("请填写物流运单号!")
										}
										var infoItems=JSON.parse(objpage)
										showloadings(true);
										$.operate.post(prefix + '/waybillNumber',{infoItems:JSON.stringify(infoItems),"waybillNumber":waybillNumber},function(result){
											if (result.code == 0) {
												setTimeout(function () {
													layer.closeAll();
													sessionStorage.setItem(moduleTable + 'checkdata', '')
													showloadings(false);
													table.reload('dhtable', {page: {curr: 1}, where: getWherestr()});
												}, 1000);
											} else {
												showloadings(false);
											}
										});
									}
								});
							},
							btn2: function(){
								return true;
							}
						});
					}
					break;
				case 'cancelTc':
					layer.confirm('确定要上传追踪编码吗?', {
						icon: 3,
						offset: '10%',
						title: "系统提示",
						btn: ['确认', '取消'],
						shadeClose:true,
						yes: function(index){
							//确认关闭当前diglog
							layer.closeAll('dialog');
							//填写备注
							layer.open({
								type: 1,
								area: ['354px', '178px'],
								title: '上传追踪编码',
								offset: '20%',
								shadeClose:true,
								content: `
									<div class="layui-form-item">
										<label class="layui-form-label"><i style="color:red">*&nbsp;&nbsp;</i>FBA编号</label>
										<div class="layui-input-block">
											<input type="text" name="remark"  required  lay-verify="required" placeholder="请输入FBA编号" autocomplete="off" class="layui-input remark"
											maxlength="20">
										</div>
									</div>
								`,
								btn: ['确认', '取消'],
								yes: function (index, layero) {
									var remark = $('.remark').val().trim()
									if (remark.replace(/(^\s*)|(\s*$)/g, "") == "") {
										return layer.msg("请填写FBA编号!")
									}
									showloadings(true);
									$.operate.post(ali1688EcpApiUrl+'/api/fbaInbound/uploadtraceNumber',{"shipmentId":remark,type:0},function(result){
										if (result.code == 0) {
											setTimeout(function () {
												layer.closeAll();
												sessionStorage.setItem(moduleTable + 'checkdata', '')
												showloadings(false);
												table.reload('dhtable', {page: {curr: 1}, where: getWherestr()});
											}, 1000);
										} else {
											showloadings(false);
										}
									});
								}
							});
						},
						btn2: function(){
							//layer.closeAll();
							return true;
						}
					});
				break;
				case 'addCEighty':
					var objpage=sessionStorage.getItem(moduleTable+'checkdata')
					if(!objpage || objpage == '[]'){
						layer.msg("请先选择数据！");
					}else{
						var infoItems=JSON.parse(objpage);
						if(infoItems.length > 1) {
							layer.msg("选择单据只允许选择一条数据,请核实后在操作!！");
							return;
						}
						if (infoItems.some(item => Number(item.stateTrack) <4)) {
							layer.msg("选择单据订单状态只允许追踪编号已导入之后,请核实后在操作!");
							return;
						}
						layer.confirm('确定要上传C88数据么?', {
							icon: 3,
							offset: '10%',
							title: "系统提示",
							btn: ['确认', '取消'],
							shadeClose:true,
							yes: function(index){
								//确认关闭当前diglog
								layer.closeAll('dialog');
								//填写备注
								layer.open({
									type: 1,
									area: ['800px', '350px'],
									title: '上传C88数据',
									offset: '20%',
									shadeClose:true,
									content: `
    								<form class="layui-form1" action="">
										<div class="layui-form-item">
											<label class="layui-form-label"><i style="color:red">*&nbsp;&nbsp;</i>进口条目编号</label>
											<div class="layui-input-block">
												<input type="text" name="entryNumber" required  lay-verify="required"  placeholder="请输入进口条目编号" autocomplete="off" class="layui-input entryNumber"
												maxlength="20" value=${infoItems[0]?.entryNumber?infoItems[0]?.entryNumber: ''}>
											</div>
										</div>
										<div class="layui-form-item">
											<label class="layui-form-label"><i style="color:red">*&nbsp;&nbsp;</i>C88文件附件</label>
											<div class="layui-input-block">
												<input type="text" class="layui-input buttontext" name="vDFilesDefault" id="vDFilesDefault" value=${infoItems[0].vDFilesDefault}  readonly="">
												<i class="layui-icon layui-icon-upload getUpload" onclick="uploadFile('${infoItems[0].guid}')" gettype="vDFilesDefault"></i>
											</div>
										</div>
									<form>
									`,
									btn: ['确认', '取消'],
									yes: function (index, layero) {
										var entryNumber = $('.entryNumber').val().trim()
										if (entryNumber.replace(/(^\s*)|(\s*$)/g, "") == "") {
											return layer.msg("请填写进口条目编号!")
										}
										var vDFilesDefault = $('#vDFilesDefault').val()
										if (vDFilesDefault == "无附件" || vDFilesDefault == undefined || vDFilesDefault == null) {
											return layer.msg("请上传C88文件附件!")
										}
										var infoItems=JSON.parse(objpage)
										showloadings(true);
										$.operate.post(prefix + '/entryNumber',{guid:infoItems[0].guid,"entryNumber":entryNumber},function(result){
											if (result.code == 0) {
												setTimeout(function () {
													layer.closeAll();
													sessionStorage.setItem(moduleTable + 'checkdata', '')
													showloadings(false);
													table.reload('dhtable', {page: {curr: 1}, where: getWherestr()});
												}, 1000);
											} else {
												showloadings(false);
											}
										});
									}
								});
							},
							btn2: function(){
								return true;
							}
						});
					}
				break;
			};
		});


		//单击选中行
		table.on('row(ftable)', function(obj){
			var code = obj.data.code;
			$('.demo2 .layui-tab-title li').removeClass('layui-this')
			$('.layui-tab-title li').attr('style','background:#fff;color:#666666');
			$('.demo2 .layui-tab-title li').eq(0).addClass('layui-this')
			$.get(prefix+'/sonlist',{code:code},function(res){
				var datalist=res.data.sonList;
				var cols=[res.data.gridColumns.gridBody];
				var totalRow=res.data.gridColumns.totalRow;
				$.tablelist.init({
					elem: '#pdhtable'
					,data:datalist
					,limit: 99999
					,where: getWherestr()
					,totalRow:totalRow
					,cols: cols
					,defaultToolbar: [{title:'列设置',layEvent: 'fieldSet',icon: 'layui-icon-set'}]
					,page:false
					// ,height:moduleTable==''?'full-46':''
					,parseData: function(res){ //res 即为原始返回的数据
						return {
							"code": res.code, //解析接口状态
							"msg": res.msg, //解析提示文本
							"count": res.count, //解析数据长度
							"data": decimalToFixed(res.data,gridColumns.decimalObj) //表格数据数值类型重赋值
						}
					}
					,done:function(res, curr, count){
						var ltv=this.elem.next('.layui-table-view');//当前table的dom
						res.data.length || count || ltv.find('.layui-table-header').css('display', 'inline-block');//数量为0时(统计报表存在不传count的情况)，表头赋予样式可拉动
						res.data.length || count || ltv.find('.layui-table-box').css('overflow-x', 'auto');//数量为0时(统计报表存在不传count的情况)，表头赋予样式可拉动
						res.data.length || count || ltv.find('.layui-table-body').css('height', ltv.find('.layui-table-body').height()-17);//数量为0时，表格高度减少滚动条高度
						$('.spxx').show()
						$('.layui-table-body.layui-table-main').eq(0).css('height', "35vh");
						$('.layui-table-body.layui-table-main').eq(1).css('height', "30vh");
						$('.layui-table-body').eq(1).css('height', "calc(35vh - 15px)");
						fixTotal(this);//修复合计行固定列问题
						if(typeof listTableDone == 'function')listTableDone();//如果查询列表存在表格加载完成回调事件，则执行
					}
					,jump:function(obj, first){
					}
				})
			})
		});

		//双击行事件：查看单据
		table.on('rowDouble(pftable)', function(obj){
			let width = ($(window).width() - 200) + 'px';
			let height = ($(window).height() - 100) + 'px';
			$.ajax({
				url: prefix + '/astm',
				type: 'post',
				data: {infoMap:JSON.stringify(obj.data)},
				dataType: 'html',
				success: function (result) {
					layer.open({
						type: 1,
						area: [width, height],
						fix: false,//不固定
						offset: '10%',//距离顶部
						maxmin: true,//最大最小化
						shade: 0.3,//遮罩
						title: '头程装箱清单',
						content:result,
						btn: ['确定', '取消'],
						shadeClose: true,// 弹层外区域关闭
					});
				}
			});
		});
	});


	// 筛选1个数组相同的数据
	function newData(arr) {
		const map = {};
		arr.forEach(item => {
			const obj = {};
			Object.keys(item).sort().map(key => obj[key] = item[key]);
			map[JSON.stringify(obj)] = item;
		});
		return Object.keys(map).map(key => JSON.parse(key));
	}

	// 筛选2个数组相同的数据
	function delData(data, deldata) {
		data.forEach(item => {
			deldata = deldata.filter(items => items.guid != item.guid);
		});
		return deldata;
	}

	let isfx = 0;
	function  importBtn(data){
		if (data === 4){
			importFields = importFields
		}  else if (data === 5){
			delete importFieldYDH['物流运单号']
			importFields = 	importFieldYDH
		} else {
			importFields = importFieldFH
		}
		isfx = data;
		if (importFields) {
			thStr = '<tr><th><div style="width:30px;">序号</div></th>';
			$.each(importFields, function (i, val) {
				fieldWidth[val] = fieldWidth[val] ? fieldWidth[val] : 100;	//默认宽度100px
				thStr += '<th><div style="width:' + fieldWidth[val] + 'px;">' + i + '</div></th>';
			})
			thStr += '</tr>';
			layer.open({
				type: 1,
				area: ['400px', '230px'],
				fix: false,
				offset: '10%',
				maxmin: true,
				shade: 0.3,
				title: '导入',
				content: `
						<form enctype="multipart/form-data" class="mt20 mb10">
							<div class="col-xs-offset-1">
							<input type="file" id="file" name="file"/>
							<div class="mt10 pt5">
							<a onclick="$.tablelist.importTemplate('/logstics/fbaLogisticsOrder/exporttemplate?num=${data}')" class="btn btn-default btn-xs"><i class="dhicon dh-file-excel-o"></i> 下载模板</a>
							</div>
							<font color="red" class="pull-left mt10">提示：仅允许导入“xls”或“xlsx”格式文件！</font>
							</div>
						</form>
												`,
				btn: ['<i class="dhicon dh-check"></i> 导入', '<i class="dhicon dh-remove"></i> 取消'],
				shadeClose: true,
				zIndex: 1000,
				btn1: function (index, layero) {
					var file = layero.find('#file');
					if (!file[0]['value']) {
						layer.msg("请选择文件！");
						return false;
					}
					var imRes = importListExcel(file[0], importFields,'fbaBox');
				}
			});
		} else {
			$.modal.alertWarning("后台未返回导入模板对象！");
		}
	}

	/*批量请求导入数据
     *tobj：导入数据对象
     *startNum：从第几条开始导入
     *oneImportNum：每次导入条数
     *allImportNum：总数据量
     *times：导入次数
     */
	function eachImport(tobj,startNum, oneImportNum, allImportNum, times, timeNum){
		var importObj = [];
		for(var i = startNum; i < allImportNum; i++){
			importObj.push(tobj[i]);
		}
		if (importObj.length ==0){
			layer.msg("导入数据为空,请核实后在操作!");
			showloadings(false);
			return;
		}
		$.ajaxSettings.async = false;
		let url;
		if (isfx === 4){
			url = prefix + '/importdatapost'
		}  else if (isfx === 5){
			url = prefix + '/batchDelivery'
		} else {
			url = prefix + '/importWaybillNumber'
		}
		//0导入追踪编号\1标记发货
		$.operate.post(url, {'infoItems':JSON.stringify(importObj)}, function(result) {
			showloadings(false);
			if(result.code == 0){
				layer.msg(result.msg)
				setTimeout(function(){
					sessionStorage.setItem(moduleTable+'checkdata','')
					layer.closeAll();
					table.reload('dhtable', {page: {curr: 1},where:getWherestr()});
				}, 1000);
			}
			if (isfx == 5 || isfx == 6){
				if(result.code ==400){
					//批量标记发货
					window.location.href = ctx + "common/download?fileName=" + encodeURIComponent(result.data) + "&delete=" + true;
					parent.$('.page-loading').hide();//页面进行了跳转刷新，需要手动关闭页面的加载动画
				}
			}
		},"json");
	}

	function uploadFile(guid){
		getUploadCommon("vDFilesDefault", "Head", guid);
	}

</script>
</body>
</html>